home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / swing / AccumulativeRunnable.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  937 b   |  41 lines

  1. package sun.swing;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.List;
  6. import javax.swing.SwingUtilities;
  7.  
  8. public abstract class AccumulativeRunnable<T> implements Runnable {
  9.    private List<T> arguments = null;
  10.  
  11.    protected abstract void run(List<T> var1);
  12.  
  13.    public final void run() {
  14.       this.run(this.flush());
  15.    }
  16.  
  17.    public final synchronized void add(T... var1) {
  18.       boolean var2 = true;
  19.       if (this.arguments == null) {
  20.          var2 = false;
  21.          this.arguments = new ArrayList();
  22.       }
  23.  
  24.       Collections.addAll(this.arguments, var1);
  25.       if (!var2) {
  26.          this.submit();
  27.       }
  28.  
  29.    }
  30.  
  31.    protected void submit() {
  32.       SwingUtilities.invokeLater(this);
  33.    }
  34.  
  35.    private final synchronized List<T> flush() {
  36.       List var1 = this.arguments;
  37.       this.arguments = null;
  38.       return var1;
  39.    }
  40. }
  41.